package com.lin.bootstudy.service.impl;

import com.lin.bootstudy.dao.UserDao;
import com.lin.bootstudy.domain.User;
import com.lin.bootstudy.service.UserSer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserSerImpl implements UserSer {

    @Autowired
    private UserDao userDao;
    @Override
    public String test() {
        User  user =userDao.selectById(1);
        System.out.println(user);
        return "finish";
    }

    @Override
    public void testUpdataPassword(int id) {
        return;
    }


    @Override
    public User selectById(int id) {
        User user = userDao.selectById(id);
        return user;
    }

    @Override
    public List<User> selectAll() {
        List<User> users = userDao.selectList(null);

        return users;
    }

    @Override
    public boolean insert(User user) {
        int i =userDao.insert(user);
        return i>0;
    }

    @Override
    public boolean update(User user) {
        int i =userDao.updateById(user);
        return i>0;
    }

    @Override
    public boolean deleteById(int id) {
        int i =userDao.deleteById(id);
        return i>0;
    }


}
